//
//  FunctionTabBarController.h
//  TaduNewUI
//  
//  自定义 TabBarView 
//  带功能按钮的 TabBarController
//
//  Created by Xu Deheng on 12-5-21.
//  Copyright (c) 2012年 ___MyCompony__ All rights reserved.
//

#if TARGET_OS_IPHONE

#import <UIKit/UIKit.h>
#import "TabBarViewDelegate.h"

#define kTABBAR_DEFAULT_HEIGHT      44.0

@class XTabBarController;
@class TabBarView;

@protocol XTabBarControllerDelegate <NSObject>
@optional
- (void)tabBarController:(XTabBarController *)tabBarController willSelectingViewController:(UIViewController *)viewController;
- (BOOL)tabBarController:(XTabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController;
- (void)tabBarController:(XTabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;
- (void)tabBarController:(XTabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers;
- (void)tabBarController:(XTabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray *)viewControllers;
- (void)tabBarController:(XTabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed;

@end

const int _item_max_count;
/*
 Has not implemented TabBarViewDelegate so far.
 */
@interface XTabBarController : UIViewController <TabBarViewDelegate>
{
@protected
    //Selected tab bar item index.
    NSUInteger _selectedIndex;
    //ViewController to selected index.
    UIViewController *_currentViewController;
    //Lock of viewControllers
    NSLock *_viewControllersLock;
    //TabBar
    TabBarView *_tabBarView;
    //Normal frame of tabBar.
    CGRect _tabBarFrame;
    NSArray *_viewControllers;
}

@property (nonatomic, assign) id<XTabBarControllerDelegate> delegate;
@property (nonatomic, retain) TabBarView *tabBarView;
@property (nonatomic, retain) NSArray *viewControllers;
@property (nonatomic, readonly) UIView *contentView;
@property (nonatomic, retain) UIViewController *currentViewController;

/*
 adjust size of content view.
 */
- (void)resizeContentView;

/*
 coordinate of tabBar item center on x axis
 Return a c-style array by NSData object.
 */
- (NSData*)xTabBarItemCoordinates;

/*
 Average distributing width of TabBarView by default.
 */
- (CGFloat)tabBarItemWidthAtIndex:(NSUInteger)atIndex;

/*
 Set the tab bar hidden with animation state.
 */
- (void)setTabBarHidden:(BOOL)isHidden animated:(BOOL)animated;

@end

#endif
